import React, {Component, PropTypes}from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router'
import CommonTitle from "../../components/CommonTitle";

class tradeSuccess extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            loading:false,
            pageindex:1,
            isLoading:true,
        }
    }
    componentWillMount() {
        document.title="交易成功";
    }
    componentDidMount() {

        // const header= {"X-Client-ID":"123456","X-Long-Token":cookie.load("token")};
        // this.props.dispatch(reset("getOrderList"));
        // this.props.dispatch(fetchPosts("getOrderList", header, {"pageindex":this.state.pageindex,"pagesize":10}));
        // this._scrollListener = Events.on(window, 'scroll', this.checkButtom.bind(this))
    }
    componentWillUnmount() {

    }

    componentWillReceiveProps(nextProps) {

    }

    render() {
        if(this.state.loading){
            return(<div className="loading"><span>loading</span></div>)
        }else{
            const orderId =  this.props.location.query.orderId;
            return(
                <div >
                    <div>
                        <ul>
                            <li>
                                <ul className="top-line">
                                    <li className="top-line-one">交易成功</li>
                                    <Link to ='mall/orderDetail' query={{orderId: orderId}}>
                                        <li className="top-line-two">查看订单</li>
                                    </Link>
                                </ul>
                            </li>
                            {/*<li>*/}
                                {/*<div className="down-line">*/}
                                    {/*<span><img/></span>*/}
                                    {/*<dl className="trade-order-list">*/}
                                        {/*<dt className="trade-dt-one">菲菲张</dt>*/}
                                        {/*<dt className="trade-dt-two">安居客的卡卡是肯定卡口打开撒</dt>*/}
                                        {/*<dt className="trade-dt-three">￥199.88</dt>*/}
                                    {/*</dl>*/}
                                    {/*<p>交易成功</p>*/}
                                {/*</div>*/}
                            {/*</li>*/}
                        </ul>
                    </div>
                </div>
            )
        }
    }
}

tradeSuccess.propTypes = {
    isFetching: PropTypes.bool.isRequired,
    dispatch: PropTypes.func.isRequired
}
tradeSuccess.contextTypes = {
    router:React.PropTypes.object
}

function mapStateToProps(state){
    const { postsByApi } = state
    const {
        isFetching,
        items: orderList
    } = postsByApi["getOrderList"] || {
        isFetching: false,
        items: {}
    }
    return {
        orderList,
        isFetching
    }
}
export default connect(mapStateToProps)(tradeSuccess);

